﻿package net.wangit.dev.group;

import net.wangit.context.ActionContext;
import net.wangit.dev.DomainAction;
import net.wangit.framework.config.UnitGroups;
import net.wangit.jdbc.DB;
import net.wangit.util.Checker;

public class DeleteGroupAction extends DomainAction {

	private static final String SQL = "delete from CGROUP where gid=? and t=?";

	public DeleteGroupAction() {
	}

	public void doAction(DB db, ActionContext ac) throws Exception {
		String groupId = ac.getRequestParameter("groupid");
		String groupType = ac.getRequestParameter("grouptype");
		if (!Checker.isEmpty(groupId) && !Checker.isEmpty(groupType)) {
			String values[] = { groupId, groupType };
			int types[] = { 2, 12 };
			db.execute(DeleteGroupAction.SQL, values, types);
			GroupReferenceUtil.update(db, domain, Integer.parseInt(groupType),
					groupId, "");
			UnitGroups.reload(domain);
		}
	}
}
